  <title>举报日志</title>

  <div class="layui-card layadmin-header">
    <div class="layui-breadcrumb" lay-filter="breadcrumb">
      <a lay-href="">主页</a>
      <a><cite>问答管理</cite></a>
      <a><cite>举报日志</cite></a>
    </div>
  </div>
  
  <div class="layui-fluid">
    <div class="layui-row layui-col-space15">
      <div class="layui-col-md12">
        <div class="layui-card">

  <!--选项卡-->
      <div class="layui-card-body">
          <div class="layui-tab layui-tab-brief" lay-filter="">
            <ul class="layui-tab-title">
              <li><a lay-href="wendasns/report/index">举报原因</a></li>
              <li class="layui-this"><a lay-href="wendasns/report/log">举报日志</a></li>
            </ul>
          </div>
      </div>

          <div class="layui-card-body">
        <div class="layui-form">
          <div class="layui-form-item">
            <div class="layui-inline"><a href="" class="layui-btn J_popup" title="确定要删除吗？"><i class="layui-icon layui-icon-delete"></i>删除</a></div>
          <div class="layui-inline"><div class="layui-input-inline"><select lay-filter="J_select">
            <option value="">帖子处理</option>
            <option value="remove">删除</option>
            <option value="hide">隐藏</option>
          </select></div></div>
          </div>
        </div>
        
            <table class="layui-hide" id="J_table_list" lay-filter="J_table_list"></table>
          </div>
          
        </div>
      </div>
    </div>
  </div>

<script type="text/html" id="J_a_tpl">
  <a style="color:#3a7ead !important;" href="{{d.url}}" target="_blank">{{d.url}}</a>
</script>

<script type="text/html" id="J_status_tpl">
  {{# if(d.status==1){ }}
  <span style="color: #5FB878;">已处理</span>
  {{# }else{ }}
  <span style="color: #FFB800;">待处理</span>
  {{# } }}
</script>

<script type="text/html" id="J_type_tpl">
  {{# if(d.type=='question'){ }}
  <span>问题</span>
  {{# }else if(d.type=='answer'){ }}
  <span>回答</span>
  {{# }else if(d.type=='article'){ }}
  <span>文章</span>
  {{# }else{ }}
  <span>评论</span>
  {{# } }}
</script>

<script type="text/html" id="J_table_tool">
  <a href="" class="layui-btn layui-btn-danger layui-btn-xs" lay-event="req" title="确定要删除吗？"><i class="layui-icon layui-icon-delete"></i>删除</a>
</script>

<script>
;!function(){
    var $ = layui.$
    ,admin = layui.admin
    ,view = layui.view
    ,form = layui.form
    ,table = layui.table;
    
    form.render('select');
    
    table.render({
      elem: '#J_table_list'
      ,url: '{:url('wendasns/report/log')}'
      ,cols: [[
        {type:'checkbox'}
        ,{field:'id', title:'ID', width:80,align:'center'}
        ,{field:'source_type', title:'帖子类型', width:100,align:'center',templet:'#J_type_tpl'}
        ,{field:'source_id', title:'被举报帖子', minWidth:120,templet:'#J_a_tpl'}
        ,{field:'num', title:'举报次数', width:100,align:'center'}
        ,{field:'create_time', title:'首次举报时间', width:160}
        ,{field:'update_time', title:'最后举报时间', width:160}
        ,{field:'status', title:'状态', width:100,align:'center',templet:'#J_status_tpl'}
        ,{field:'reason', title:'举报原因',align:'center',width:120,templet:'<div><a class="layui-btn layui-btn-normal layui-btn-xs J_reasonSee" data-id="{{d.id}}">查看</a></div>'}
        ,{title:'操作',width:100,align:'center',toolbar:'#J_table_tool'}
      ]]
  ,page: true
    ,limit: 20
    ,height: 'auto'
     ,text: '暂无数据'
    })

  form.on('select(J_select)', function(obj){
		var data = table.checkStatus('J_table_list'),post = [];
  	  	$.each(data.data,function(){
  	  		post.push(this.id);
        });
			if(post.length === 0){
				return layer.msg('\u8bf7\u9009\u62e9\u6570\u636e');
			}
		admin.req({
			url: '{:url('wendasns/report/chuli')}'
			,type: 'post'
			,data: {status:obj.value,id:post}
			,done: function(res){
				
			}
		});
  });


  $(document).on('click', 'a.J_reasonSee', function(){
    var id = $(this).data('id');

  	  	  admin.popup({
      	  title: '举报原因/举报人'
          ,area: ['700px', '500px']
          ,id: 'LAY-popup-table'
          ,success: function(layero, index){
        	view(this.id).render('wendasns/report/reason', {id:id}).done(function(){
              
          });
        }
      	  });
      
  });
  
}();
</script>